from django.conf.urls import url
from . import views
from rest_framework_jwt.views import obtain_jwt_token

urlpatterns = [
    #/users/usernames/(?P<username>\w{5,20})/
    url(r'^usernames/(?P<username>\w{5,20})/$',views.RegisterUsernameView.as_view(),name='usernamecount'),

    url(r'^$',views.RegisterCreateUserView.as_view()),

    url(r'^auths/',obtain_jwt_token),

    url(r'^infos/$',views.UserCenterInfoView.as_view()),

    url(r'^emails/$',views.UserUpdateEmailView.as_view()),

    url(r'^emails/verification/$',views.UserEmailActiveView.as_view()),

    url(r'^addresses/$',views.AddressView.as_view()),

    url(r'^browerhistories/$',views.UserHistoryView.as_view()),
]

"""
    header:             eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
    payload:            eyJ1c2VybmFtZSI6ImRkZGRkIiwiZXhwIjoxNTQxNTc5NDA0LCJ1c2VyX2lkIjoxMCwiZW1haWwiOiIifQ.
    signature:         sEDjxCkOqWrDUg-vEwhGGdRAAV_8FmCKZN_Q0XUMiwA
"""

"""
1. 当我们去输入用户名和密码的时候,我们是传递给了 jwt_token
    rest_framework_jwt 是建立在 rest_framework的基础之上的,
    rest_framework_jwt 的认证 也是建立在 rest_framework
2.  系统只是使用的用户名来进行的判断,
    我们的需求是 除了用户名还需要使用手机号进行登录


    User.objects.get(moble=mobile)
    User.objects.get(username=username)

    如果是 手机号 我们根据手机号进行查询
    如果是 用户名 我们根据用户名进行查询
"""
from django.contrib.auth.backends import  ModelBackend